//
//  YTCarsManagerViewCell.m
//  YiTuDriverClient
//
//  Created by 石少庸 on 2017/8/2.
//  Copyright © 2017年 Yitu. All rights reserved.
//

#import "YTCarsManagerViewCell.h"
#import <YYWebImage/YYWebImage.h>
#import "YTDriverCarModel.h"

@interface YTCarsManagerViewCell ()

@property (weak, nonatomic) IBOutlet UILabel *carLevelText;
@property (weak, nonatomic) IBOutlet UIImageView *contenImg;
@property (weak, nonatomic) IBOutlet UILabel *titleText;
@property (weak, nonatomic) IBOutlet UIButton *deleteBtn;
@property (weak, nonatomic) IBOutlet UILabel *carSeatsText;
@property (weak, nonatomic) IBOutlet UILabel *carStatesText;
@property (weak, nonatomic) IBOutlet UILabel *carUseStatesText;

@end

@implementation YTCarsManagerViewCell

- (void)setModel:(YTDriverCarModel *)model {
    _model = model;
    _titleText.text = model.carTitle;
    [_contenImg yy_setImageWithURL:[NSURL URLWithString:model.carImage] placeholder:[UIImage imageNamed:@"car_placehouder"]];
    _carLevelText.text = (model.carClassName.length ? model.carClassName : @"未设置");
    _carSeatsText.text = (model.seatTypeName.length ? model.seatTypeName : @"未设置");
    _carUseStatesText.text = model.status == 1 ? @"使用中" : @"未使用";
    switch (model.applyStatus) {
        case 0:
            _carStatesText.text = @"已提交未审核";
            break;
        case 1:
            _carStatesText.text = @"审核通过";
            break;
        case 3:
            _carStatesText.text = @"审核不通过";
            break;
        case 4:
            _carStatesText.text = @"更新中";
            break;
    }
    
    _carStatesText.textColor = (model.applyStatus == 1 ? kBlackColor : [UIColor redColor]);
}

- (IBAction)deleteAction:(UIButton *)sender {
    if (_deleteAction) {
        _deleteAction(_model.carId);
    }
}

- (void)prepareForReuse {
    [super prepareForReuse];
    _carStatesText.textColor = kBlackColor;
}

@end
